import request from '@/config/axios'

// 设备型号 VO
export interface DevModelVO {
  category: string // 分类名
  brand: string // 品牌
  model: string // 型号
}

// 设备 VO
export interface DeviceVO {
  id: number // id
  devCodeIntrinsic: string
  devCodeHosp: string
  devCodeDept: string
  devId: string // 设备编号
  category: string // 分类名
  brand: string // 品牌
  model: string // 型号
  purchaseDate: number // 采购日期
  state: number //状态
  comment: string // 备注
}

// 设备统计 VO
export interface DeviceStatisticVO {
  id: number  // id
  devId: string  // 设备编号
  category: string  // 分类名
  brand: string  // 品牌
  model: string  // 型号
  purchaseDate: number // 采购日期
  state: number // 状态
  devCount: number // 统计数量
}

export interface OptionsVO {
  label: string
  value: string
}

// 设备型号 API
export const DevModelApi = {
  // 查询设备型号分页
  getDevModelPage: async (params: any) => {
    return await request.get({ url: `/ecg/dev-model/page`, params })
  },

  // 查询设备型号详情
  getDevModel: async (id: number) => {
    return await request.get({ url: `/ecg/dev-model/get?id=` + id })
  },

  // 新增设备型号
  createDevModel: async (data: DevModelVO) => {
    return await request.post({ url: `/ecg/dev-model/create`, data })
  },

  // 修改设备型号
  updateDevModel: async (data: DevModelVO) => {
    return await request.put({ url: `/ecg/dev-model/update`, data })
  },

  // 删除设备型号
  deleteDevModel: async (id: number) => {
    return await request.delete({ url: `/ecg/dev-model/delete?id=` + id })
  },

  // 导出设备型号 Excel
  exportDevModel: async (params) => {
    return await request.download({ url: `/ecg/dev-model/export-excel`, params })
  },

  //
  getBrandOption: async (category: string) => {
    return await request.get({ url: `/ecg/dev-model/brand-option?category=` + category })
  },

  getModelOption: async (category: string, brand: string) => {
    return await request.get({ url: `/ecg/dev-model/model-option?category=` + category + `&brand=` + brand })
  }
}

// 设备 API
export const DeviceApi = {
  // 查询设备分页
  getDevicePage: async (params: any) => {
    return await request.get({ url: `/ecg/device/page`, params })
  },

  // 设备统计
  deviceStatistic: async (params: any) => {
    return await request.get({ url: `/ecg/device/dev-statistic`, params })
  },

  // 查询设备详情
  getDevice: async (id: number) => {
    return await request.get({ url: `/ecg/device/get?id=` + id })
  },

  // 查询设备详情
  getDeviceByDevId: async (devId: string) => {
    return await request.get({ url: `/ecg/device/get-by-dev-id?dev-id=` + devId })
  },

  // 新增设备
  createDevice: async (data: DeviceVO) => {
    return await request.post({ url: `/ecg/device/create`, data })
  },

  // 修改设备
  updateDevice: async (data: DeviceVO) => {
    return await request.put({ url: `/ecg/device/update`, data })
  },

  // 修改设备状态
  updateDeviceState: async (data: DeviceVO) => {
    return await request.post({ url: `/ecg/device/update-dev-state`, data })
  },

  // 删除设备
  deleteDevice: async (id: number) => {
    return await request.delete({ url: `/ecg/device/delete?id=` + id })
  },

  // 导出设备 Excel
  exportDevice: async (params) => {
    return await request.download({ url: `/ecg/device/export-excel`, params })
  }
}
